package com.cyandpos.pad.presentation;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cyandpos.pad.R;
import com.cyandpos.pad.common.commondata.ErpCommonData;
import com.cyandpos.pad.posdata.Goods;
import com.cyandpos.pad.posdata.Payment;
import com.cyandpos.pad.utils.MoneyUtils;

import java.util.List;

public class AdPresentationPayAdapter extends BaseAdapter {
    private Context context;
    private List<Payment> list;

    public AdPresentationPayAdapter(Context context,List<Payment> list){
        this.context=context;
        this.list=list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Payment getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_presentation_pay,null);
            holder=new Holder();
            holder.tv_name=convertView.findViewById(R.id.pay_name);
            holder.tv_money=convertView.findViewById(R.id.pay_name_money);
            convertView.setTag(holder);
        }else{
            holder= (Holder) convertView.getTag();
        }
        Payment payment=getItem(position);
        if(payment!=null){
            holder.tv_name.setText(payment.getPayName());
            holder.tv_money.setText(MoneyUtils.getMoneyStr(MoneyUtils.getMoneyInt(payment.getPayAmount())));
        }
        return convertView;
    }

    class Holder{

        private TextView tv_name;
        private TextView tv_money;
    }
}


